var t = require("../../utils/config"), e = require("../../utils/request"), a = require("../../utils/api"), o = require("../../utils/date"), r = require("../../utils/storage");

Component({
    properties: {
        marginTop: {
            type: String,
            value: "0px"
        }
    },
    data: {
        themeColor: getApp().globalData.themeColor,
        x: getApp().globalData.systemWidth / 2 - 30,
        btnX: getApp().globalData.systemWidth / 4 - 30,
        qrCodeImgUrl: t.resourceRoot + "icon-qrcode.png",
        reservationList: [],
        showReservationList: !1,
        showQrCode: !1,
        reservationNo: "",
        qrCode: ""
    },
    lifetimes: {
        attached: function() {},
        ready: function() {
            this.getCurrentDayReservation();
        }
    },
    methods: {
        getCurrentDayReservation: function() {
            var t = this;
            if (r.isLogin()) {
                this.setData({
                    reservationList: []
                });
                var i = o.formatDate(new Date(), "yyyy-MM-dd");
                e.request(e.HttpMethod.GET, a.apiRoute.getCurrentDayReservation + "?rDate=" + i, {}).then(function(e) {
                    e.success && e.data.length > 0 && (null != e.data && e.data.legth >= 2 ? t.setData({
                        reservationList: e.data.slice(0, 2),
                        showReservationList: !0
                    }) : t.setData({
                        reservationList: e.data,
                        showReservationList: !0
                    }));
                });
            }
        },
        getTodayReservationMore: function() {
            wx.navigateTo({
                url: "/pages/today-reservation/today-reservation"
            });
        },
        goCheck: function(o) {
            var i = this;
            t.getH5ResvDetailUrl().then(function(t) {
                var s = r.getStorageSync(r.storageKey.uid), n = o.target.dataset.item.checkCardNo, c = !([ "CRS_BulkLd", "ZJ_OutSideInPut", "WEB_BulkResv", "PQ_Bulkld", "PQ_BulkLd", "KA_Family", "KA_WEB_BULK_RESV" ].indexOf(o.target.dataset.item.sourceValue) >= 0), d = o.target.dataset.item.resvPid || "", u = o.target.dataset.item.vip || "0", l = o.target.dataset.item.companyCode, g = o.target.dataset.item.ldNo, h = o.target.dataset.item.isVcard || !0, v = s || "", p = "cardNo=".concat(n, "&bindCard=").concat(c, "&isVIP=").concat(u, "&resvPid=").concat(d, "&companyID=").concat(l, "&ldNo=").concat(g, "&showButton=true&isVCard=").concat(h, "&source=wechatAppletNew&operator=").concat(v), m = t, y = r.getStorageSync(r.storageKey.locationInfo);
                null != y && null != y && "" != y && (p += "&pointY=".concat(y.latitude, "&pointX=").concat(y.longitude)), 
                console.log(p), e.request(e.HttpMethod.POST, a.apiRoute.encodeResvUrl, {
                    urlpara: p
                }).then(function(t) {
                    var e = "".concat(m, "&accesskey=").concat(t.url);
                    wx.navigateTo({
                        url: "/pages/webview/webview?h5=".concat(encodeURIComponent(e)),
                        success: function() {
                            i.setData({
                                loading: !1
                            });
                        }
                    });
                });
            });
        },
        createQrCode: function(t) {
            var o = this, r = t.target.dataset.item.resvNo;
            this.setData({
                reservationNo: r
            }), e.request(e.HttpMethod.GET, a.apiRoute.createQrCode + "?text=".concat(r, "&width=300&height=300"), {}).then(function(t) {
                t.success && t.data.length > 0 && o.setData({
                    qrCode: t.data,
                    showQrCode: !0
                });
            });
        }
    }
});